﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace InstaMe
{
    public class RefreshViewCommand : ICommand
    {
        readonly Action mExecute;
        readonly Predicate<object> mCanExecute;

        public RefreshViewCommand(Action aAction)
            : this(aAction, null)
        {
        }

        public RefreshViewCommand(Action aAction, Predicate<object> aPredicate)
        {
            mExecute = aAction;
            mCanExecute = aPredicate;
        }

        public bool CanExecute(object parameter)
        {
            return mCanExecute == null ? true : mCanExecute(parameter);
        }

        public event EventHandler CanExecuteChanged;

        public void Execute(object parameter)
        {
            if (mExecute != null)
            {
                mExecute();
            }
        }
    }
}
